package com.ruoyi.module.service.impl;

import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.module.mapper.UserChapterRecordMapper;
import com.ruoyi.module.domain.UserChapterRecord;
import com.ruoyi.module.service.IUserChapterRecordService;
import com.ruoyi.common.utils.SecurityUtils;

/**
 * 用户章节学习记录Service业务层处理
 * 
 * @author ruoyi
 */
@Service
public class UserChapterRecordServiceImpl implements IUserChapterRecordService 
{
    @Autowired
    private UserChapterRecordMapper userChapterRecordMapper;

    /**
     * 查询用户章节学习记录
     */
    @Override
    public UserChapterRecord selectUserChapterRecordById(Long id)
    {
        return userChapterRecordMapper.selectUserChapterRecordById(id);
    }

    /**
     * 查询用户章节学习记录列表
     */
    @Override
    public List<UserChapterRecord> selectUserChapterRecordList(UserChapterRecord userChapterRecord)
    {
        if (userChapterRecord.getUserId() == null) {
            userChapterRecord.setUserId(SecurityUtils.getUserId());
        }
        return userChapterRecordMapper.selectUserChapterRecordList(userChapterRecord);
    }

    /**
     * 新增用户章节学习记录
     */
    @Override
    public int insertUserChapterRecord(UserChapterRecord userChapterRecord)
    {
        if (userChapterRecord.getUserId() == null) {
            userChapterRecord.setUserId(SecurityUtils.getUserId());
        }
        return userChapterRecordMapper.insertUserChapterRecord(userChapterRecord);
    }

    /**
     * 修改用户章节学习记录
     */
    @Override
    public int updateUserChapterRecord(UserChapterRecord userChapterRecord)
    {
        return userChapterRecordMapper.updateUserChapterRecord(userChapterRecord);
    }

    /**
     * 批量删除用户章节学习记录
     */
    @Override
    public int deleteUserChapterRecordByIds(Long[] ids)
    {
        return userChapterRecordMapper.deleteUserChapterRecordByIds(ids);
    }

    /**
     * 删除用户章节学习记录信息
     */
    @Override
    public int deleteUserChapterRecordById(Long id)
    {
        return userChapterRecordMapper.deleteUserChapterRecordById(id);
    }
}

